class ListNode {
    int val;
    ListNode next = null;

    ListNode(int val) {
        this.val = val;
    }
}

public class Text {
    public ListNode deleteDuplication(ListNode pHead) {
        if(pHead == null) {
            return pHead;
        }
        ListNode head = new ListNode(0);
        head.next = pHead;
        ListNode prev = head;
        ListNode cur = pHead;
        while(cur != null) {
            while(cur.next != null && cur.val != cur.next.val) {
                prev = prev.next;
                cur = cur.next;
            }
            while(cur.next != null && cur.val == cur.next.val) {
                cur = cur.next;
            }
            if(prev.next != cur) {
                prev.next = cur.next;
            }
            cur = cur.next;
        }
        return head.next;
    }
}
class MyHashMap {
    static class Node {
        public int key;
        public int val;
        public Node next;
        public Node(int key,int val) {
            this.key = key;
            this.val = val;
        }
    }
    public Node[] array;
    public int usedsize;

    public MyHashMap() {
        array = new Node[10];
        usedsize = 0;
    }

    public void put(int key, int value) {
        int index = key % array.length;
        Node cur = array[index];
        while(cur != null) {
            if(cur.key == key) {
                cur.val = value;
                return;
            }
        }
        Node node = new Node(key,value);
        node.next = array[index];
        array[index] = node;
        usedsize++;
        if(loadFactor() >0.75) {
            resize();
        }
    }

    public double loadFactor() {
        return usedsize*1.0/array.length;
    }

    public void resize() {
        Node[] newArray = new Node[array.length*2];
        for(int i = 0; i<array.length;i++) {
            Node cur = array[i];
            while(cur != null) {
                Node curNext = cur.next;
                int index = cur.key % newArray.length;
                cur.next = newArray[index];
                newArray[index] = cur;
                cur = curNext;
            }
        }
        array = newArray;
    }

    public int get(int key) {
        int index = key % array.length;
        Node cur = array[index];
        while(cur != null) {
            if(cur.key == key) {
                return cur.val;
            }
            cur = cur.next;
        }
        return -1;
    }

    public void remove(int key) {
        int index = key % array.length;
        Node cur = array[index];
        Node prev = null;
        while(cur != null) {
            if(cur.key == key) {
                if(prev == null) {
                    array[index] = cur.next;
                }else {
                    prev.next = cur.next;
                }
                return;
            }
            prev = cur;
            cur = cur.next;
        }
    }
}
